<template>
  <div>
    <div class="py-1 px-1 bg-white">
      <div v-for="(item, index) in descList" :key="index">
        <div>
          <custom-details-item :icon="item.icon" :label="item.label" :value="item.value">
            <template #valueSlot>
              <span v-if="item.label !== '附件'">{{ item.value }}</span>
              <el-link v-else type="primary">{{ item.value }}</el-link>
            </template>
          </custom-details-item>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { aqCompanyInfo } from '@/api/enterprise'

export default {
  inject: ['layout'],
  data() {
    return {
      current: '',
      companyId: '',
      companyName: '',
      descList: [
        { label: '企业名称', value: '', fieldName: 'companyName', icon: '&#xe725;' },
        { label: '风险单元', value: '', fieldName: 'riskName', icon: '&#xe7e5;' },
        { label: '风险低名称', value: '', fieldName: 'riskUnit', icon: '&#xe87e;' },
        { label: '风险点界别', value: '', fieldName: 'dangerLevel', icon: '&#xe634;' },
        { label: '可能导致的事故类别', value: '', fieldName: 'accidentType', icon: '&#xe70f;' },
        { label: '危险有害因素', value: '', fieldName: 'isBIg', icon: '&#xe994;' },
        { label: '管控措施', value: '', fieldName: 'controller', icon: '&#xe994;' },
        { label: '责任人', value: '', fieldName: 'districtName', icon: '&#xe60d;' },
        { label: '评估时间', value: '', fieldName: 'identifyTime', icon: '&#xe685;' }
      ],
      factoryImgList: []
    }
  },
  mounted() {
    const { current, companyId } = this.$route.query
    this.companyId = companyId || ''
    this.current = current || ''
    this.$nextTick(() => {
      // this.companyInfoBasic()
      this.descList.forEach((v) => {
        v.value = this.$route.query[v.fieldName]
      })
    })
  },
  methods: {
    // 获取企业详情数据--基本信息
    async companyInfoBasic() {
      this.layout.showAreaLoading(['.el-descriptions'])
      const { status, data } = await aqCompanyInfo({ companyId: this.companyId })
      if (status === 0 && data) {
        this.companyName = data.companyName
        this.descList.forEach((v) => {
          if (v.label === '所在地') {
            let valueTemp = ''
            v.fieldName.split(',').forEach((v) => {
              valueTemp += data[v] ? data[v] : ''
            })
            v.value = valueTemp
          } else {
            v.value = data[v.fieldName] ? data[v.fieldName] : ''
          }
        })
      }
      this.layout.hideAreaLoading(['.el-descriptions'])
    }
  }
}
</script>

<style lang="scss" scoped>
.olMap {
  width: 100%;
  height: 350px;
}
</style>
